package com.afd.ozblip.activity;

import java.util.List;

import com.afd.ozblip.entity.VipEntity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class VipDetailActivity extends BaseActivity {

	/****************** 视图变量 **************************/
	private LinearLayout addVipLayout;
	private LinearLayout toBusinessLayout;
	private TextView businessNameTv;
	private TextView vipTitleTv;
	private TextView vipContentTv;

	/****************** 数据变量 **************************/
	private VipEntity vipInfo ;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vip_detail);
		// 启动返回功能
		toBack();
		// 寻找视图
		findViews();
		// 设置监听
		setListeners();
		// 获取参数
		getBundle();
		// 给视图赋值
		setViews();
	}

	/**
	 * 寻找视图
	 */
	public void findViews() {
		this.addVipLayout = (LinearLayout) findViewById(R.id.ll_vip_addBtn);
		this.toBusinessLayout = (LinearLayout) findViewById(R.id.ll_vip_toBusiness);
		this.businessNameTv = (TextView) findViewById(R.id.tv_vip_detail_businessName);
		this.vipTitleTv = (TextView) findViewById(R.id.tv_vip_detail_title);
		this.vipContentTv = (TextView) findViewById(R.id.tv_vip_detail_content);
	}

	/**
	 * 设置监听
	 */
	public void setListeners() {
		View.OnClickListener vipDetailClick = new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				switch (v.getId()) {
				case R.id.ll_vip_addBtn:
					Intent settingIntent = new Intent(VipDetailActivity.this,
							AddVipActivity.class);
					settingIntent.putExtra("businessId", vipInfo.getBusinessId());
					settingIntent.putExtra("vipId", vipInfo.getVipId());
					startActivity(settingIntent);
					break;
				case R.id.ll_vip_toBusiness:
					Intent businessIntent = new Intent(VipDetailActivity.this,
							BusinessInfoActivity.class);
					businessIntent.putExtra("businessId", vipInfo.getBusinessId());
					startActivity(businessIntent);
					break;

				default:
					break;
				}
			}
		};
		this.addVipLayout.setOnClickListener(vipDetailClick);
		this.toBusinessLayout.setOnClickListener(vipDetailClick);
	}

	/**
	 * 获取传递的参数
	 */
	private void getBundle() {
		Intent intent = getIntent();
		vipInfo = (VipEntity) intent.getSerializableExtra("vipInfo");
	}
	
	private void setViews(){
		if(vipInfo!=null){
			this.businessNameTv.setText(vipInfo.getBusinessName());
			this.vipTitleTv.setText(vipInfo.getVipTitle());
			this.vipContentTv.setText(vipInfo.getVipContent());
		}
		
	}
}